/********************************************************************
	Created:	2011/02/22    17:35 
	Filename: 	Vec2D.h
	Author:		falconwang
*********************************************************************/

#ifndef Vec2D_H__
#define Vec2D_H__

namespace Core
{
	template <class T>
	class Vec2D
	{
	public:

		Vec2D() : x(0), y(0) {}
		Vec2D(T _x, T _y) : x(_x), y(_y) {}
		Vec2D(const Vec2D<T>& _other) : x(_other.x), y(_other.y) {}

		bool operator == (const Vec2D<T>& _other) const
		{
			return x == _other.x && y == _other.y;
		}

		bool operator != (const Vec2D<T>& _other) const
		{
			return x != _other.x || y != _other.y;
		}

		const Vec2D<T>& operator+=(const Vec2D<T>& _other)
		{
			x += _other.x;
			y += _other.y;
			return *this;
		}

		const Vec2D<T>& operator-=(const Vec2D<T>& _other)
		{
			x -= _other.x;
			y -= _other.y;
			return *this;
		}

		Vec2D<T> operator-(const Vec2D<T>& _other) const
		{
			return Vec2D<T>(x-_other.x, y-_other.y);
		}

		Vec2D<T> operator+(const Vec2D<T>& _other) const
		{
			return Vec2D<T>(x+_other.x, y+_other.y);
		}

		Vec2D<T> operator*(const Vec2D<T>& _other) const
		{
			return Vec2D<T>(x*_other.x, y*_other.y);
		}

		Vec2D<T> operator*(const T& _scalar) const
		{
			return Vec2D<T>(x*_scalar, y*_scalar);
		}

		Vec2D<T> operator/(int _div) 
		{
			return Vec2D<T>(x / _div, y / _div);
		}

		const Vec2D<T>& operator=(const Vec2D<T>& _other)
		{
			x = _other.x;
			y = _other.y;
			return *this;
		}
	public:

		T	x;
		T	y;
	};

	typedef Vec2D<float> Vec2Df;
	typedef Vec2D<int>   Vec2Di;
}

#endif // Vec2D_H__